package com.example.sunmiv1.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.sunmiv1.R;
import com.example.sunmiv1.adapter.IndexPageAdapter;
import com.example.sunmiv1.entity.IndexPageBean;
import com.example.sunmiv1.utils.net.ACache;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
//採購管理
public class PurchaseManageActivity extends Activity {


    @BindView(R.id.title_back)
    ImageView titleBack;
    @BindView(R.id.title_title)
    TextView titleTitle;
    @BindView(R.id.purchaseManage_gridView)
    GridView purchaseManageGridView;

    private Context context;
    private ACache aCache;
    private Intent intent;
    private IndexPageAdapter indexPageAdapter;
    private List<IndexPageBean> indexList = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_purchase_manage);
        ButterKnife.bind(this);
        titleTitle.setText(R.string.purchaseManageTitle);
        context = this;
        aCache = ACache.get(context);
        initListener();
    }

    private void initListener() {
        indexList.add(new IndexPageBean(R.mipmap.good_warehousing, R.string.purchaseManage_order));//採購單
        indexList.add(new IndexPageBean(R.mipmap.index_deposit, R.string.purchaseManage_refund));//採購退貨
        indexPageAdapter = new IndexPageAdapter(context, indexList);
        purchaseManageGridView.setAdapter(indexPageAdapter);
        purchaseManageGridView.setOnItemClickListener((parent, view, position, id) -> {
            switch (indexList.get(position).getImg()) {
                case R.mipmap.good_warehousing://採購單
                        intent = new Intent(context, PurchaseOrderActivity.class);
                        startActivity(intent);
                    break;
                case R.mipmap.index_deposit://採購退貨
                        intent = new Intent(context, PurchaseRefundActivity.class);
                        startActivity(intent);
                    break;
            }
        });
    }

    @OnClick(R.id.title_back)
    public void onViewClicked() {
        finish();
    }
}
